<template>
	<section>
		<!--工具条-搜索区域-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 2px;">
			<el-form :inline="true" :model="queryFrom">
				<el-form-item>
					<el-input v-model="queryFrom.keyword" placeholder="权限名称"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getPermission1">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-数据区域-->
		<el-table :data="list" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<el-table-column type="index"  label="编号" width="150">
			</el-table-column>
			<el-table-column prop="name" label="权限名称" width="220" sortable>
			</el-table-column>
      <el-table-column prop="descs" label="权限介绍" width="300" sortable>
      </el-table-column>
      <el-table-column prop="parent.name" label="父级权限名称" width="220" sortable>
      </el-table-column>
      <el-table-column prop="parent.descs" label="父级权限介绍" width="300" sortable>
      </el-table-column>
		</el-table>

		<!--工具条-分页-->
		<el-col :span="24" class="toolbar">
      <el-pagination
          style="float:right;"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page=this.queryFrom.currentPage
          :page-sizes="[3, 5, 10, 20]"
          :page-size=this.queryFrom.pageSize
          layout="total, sizes, prev, pager, next, jumper"
          :total=this.total>
      </el-pagination>
		</el-col>


	</section>
</template>

<script>

	export default {
		data() {
			return {
			  queryFrom:{
			    pageSize:10,
          currentPage:1,
          keyword:""
        },
        list: [],
				total: 0,
				page: 1,
				listLoading: false,
				sels: [],
			}
		},
		methods: {
		  //handleSizeChange
      handleSizeChange(val){
        //设置页面条数的时候会被触发，val是显示条数
        this.queryFrom.pageSize = val;
        this.getPermission()
      },
			handleCurrentChange(val) {
        this.queryFrom.currentPage = val;
				this.getPermission();
			},
      //获取权限列表
			getPermission() {
				this.listLoading = true;
        // 发送请求 请求后台
        this.$http.post("/permission",this.queryFrom)
            .then(res=>{
          res = res.data.data
          this.list = res.list
          this.total = res.total
          console.log(res)
          this.listLoading = false;
            })
            .catch(res=>{

            })
			},
      //根据条件查询
      getPermission1() {
        //当查询时跳转回第一页
        this.queryFrom.currentPage=1;
        this.listLoading = true;
        // 发送请求 请求后台
        this.$http.post("/permission",this.queryFrom)
            .then(res=>{
              res = res.data.data
              this.list = res.list
              this.total = res.total
              console.log(res)
              this.listLoading = false;
            })
            .catch(res=>{
            })
      },
		},
		mounted() {
			this.getPermission();
		}
	}

</script>

<style scoped>

</style>